#ifndef INCLUDED_KEY_H
#define INCLUDED_KEY_H

//====================================================================================================
// Filename:	Key.h
// Created by:	Peter Chan
// Description:	Provides a function for generating a hash key using a null terminated string.
//====================================================================================================

//====================================================================================================
// Includes
//====================================================================================================

#include <string>

//====================================================================================================
// Namespace
//====================================================================================================

namespace Utility
{

//====================================================================================================
// Typedefs
//====================================================================================================

typedef unsigned int Key;

//====================================================================================================
// Function Declarations
//====================================================================================================

// Function to generate a key from a null terminated string
inline Key MakeKey(const char* pString);

//====================================================================================================
// Function Definitions
//====================================================================================================

inline Key MakeKey(const char* pString)
{
	Key iKey = 0;

	const int kLength = static_cast<int>(strlen(pString));
	for (int i = 0; i < kLength; ++i)
	{
		iKey = (iKey * 31) + pString[i];
	}

	return iKey;
}

} // namespace Utility

#endif // #ifndef INCLUDED_KEY_H